﻿namespace DailyFx.UI {
    using System;

    /// <summary>
    /// A logger.
    /// </summary>
    public interface ILog
	{
        /// <summary>
        /// Logs the message as info.
        /// </summary>
        /// <param name="format">A formatted message.</param>
        /// <param name="args">Parameters to be injected into the formatted message.</param>
        void Info(string format, params object[] args);

        /// <summary>
        /// Logs the message as a warning.
        /// </summary>
        /// <param name="format">A formatted message.</param>
        /// <param name="args">Parameters to be injected into the formatted message.</param>
        void Warn(string format, params object[] args);

        /// <summary>
        /// Logs the exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        void Error(Exception exception);
    }

	class NullLog : ILog
	{
		public void Info ( string format, params object[] args )
		{
			// nothing
		}
		public void Warn ( string format, params object[] args ) 
		{
			// nothing
		}
		public void Error( Exception exception ) 
		{
			// nothing
		}
	}

    /// <summary>
    ///		Used to manages logging.
    /// </summary>
    public static class LogManager 
	{
        static readonly ILog NULL = new NullLog();

        /// <summary>
        /// Creates an <see cref="ILog"/> for the provided type.
        /// </summary>
		public static Func<Type, ILog> GetLog = type => NULL ;

    }
}